package com.zkthink.ceres.product.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.zkthink.base.entity.Entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import com.zkthink.base.entity.SuperEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

import org.apache.ibatis.annotations.Select;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import java.time.LocalDateTime;
import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.zkthink.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 专题表
 * </p>
 *
 * @author JustArgo
 * @since 2020-09-11
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "ceres_subject",resultMap = "BaseResultMap")
@ApiModel(value = "Subject", description = "专题表")
@AllArgsConstructor
public class Subject extends Entity<Long> {

    private static final long serialVersionUID = 1L;

    /**
     * 专题key
     */
    @ApiModelProperty(value = "专题key")
    @NotEmpty(message = "专题key不能为空")
    @Length(max = 255, message = "专题key长度不能超过255")
    @TableField(value = "subject_key", condition = LIKE)
    @Excel(name = "专题key")
    private String subjectKey;

    /**
     * 专题名称
     */
    @ApiModelProperty(value = "专题名称")
    @NotEmpty(message = "专题名称不能为空")
    @Length(max = 32, message = "专题名称长度不能超过32")
    @TableField(value = "title", condition = LIKE)
    @Excel(name = "专题名称")
    private String title;

    /**
     * banner图片，可以存储多张
     */
    @ApiModelProperty(value = "banner图片，可以存储多张")
    @Length(max = 65535, message = "banner图片，可以存储多张长度不能超过65535")
    @TableField("banner")
    @Excel(name = "banner图片，可以存储多张")
    private String banner;

    /**
     * 专题小图
     */
    @ApiModelProperty(value = "专题小图")
    @Length(max = 255, message = "专题小图长度不能超过255")
    @TableField("small_image")
    @Excel(name = "专题小图")
    private String smallImage;

    /**
     * 子标题
     */
    @ApiModelProperty(value = "子标题")
    @NotEmpty(message = "子标题不能为空")
    @Length(max = 32, message = "子标题长度不能超过32")
    @TableField(value = "sub_title", condition = LIKE)
    @Excel(name = "子标题")
    private String subTitle;

    /**
     * 是否删除 1-删除 0-不删除
     */
    @ApiModelProperty(value = "是否删除 1-删除 0-不删除")
    @NotNull(message = "是否删除 1-删除 0-不删除不能为空")
    @TableField("is_delete")
    @Excel(name = "是否删除 1-删除 0-不删除", replace = {"是_true", "否_false", "_null"})
    private Boolean isDelete;

    @ApiModelProperty("专题关联商品")
    @NotEmpty(message = "专题关联商品不能为空")
    @TableField(exist = false)
    private List<SubjectProduct> subjectProductList;

    @Builder
    public Subject(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser,
                    String title, String banner, String subTitle, Boolean isDelete) {
        this.id = id;
        this.createTime = createTime;
        this.createUser = createUser;
        this.updateTime = updateTime;
        this.updateUser = updateUser;
        this.title = title;
        this.banner = banner;
        this.subTitle = subTitle;
        this.isDelete = isDelete;
    }

}
